<template>
  <div>
    <el-tooltip
      v-for="item in paperColRadioOptions"
      :key="item.value"
      :content="item.tips"
      :placement="item.tipPosition"
    >
      <el-radio
        v-model="paperColCount"
        :label="item.value"
      >
        {{ item.title }}
      </el-radio>
    </el-tooltip>
  </div>
</template>

<script>
import { mapState, mapMutations } from 'vuex';

export default {
  data() {
    return {
      paperColCount: 1,
      paperColRadioOptions: [
        {
          title: '一栏',
          value: 1,
          tips: '一栏适用于A4纸张',
          tipPosition: 'top-start',
        },
        {
          title: '二栏',
          value: 2,
          tips: '两栏适用于A3纸张',
          tipPosition: 'top',
        },
        // {
        //   title: '三栏',
        //   value: 3,
        //   tips: '三栏适用于A3纸张',
        //   tipPosition: 'top-end',
        // },
      ],
    };
  },
  computed: {
    ...mapState({
      pcc: 'paperColCount',
    }),
  },
  watch: {
    pcc(val) {
      this.paperColCount = val;
    },
    paperColCount(val) {
      const paperColCount = val;
      let paperType;
      if (paperColCount === 1) {
        paperType = 'A4';
      } else {
        paperType = 'A3';
      }
      this.updatePaper({ paperType, paperColCount });
    },
  },
  created() {
    this.paperColCount = this.pcc;
  },
  methods: {
    ...mapMutations([
      'updatePaper',
    ]),
  },
};
</script>
